package com.live.receiver;

import android.app.KeyguardManager;
import android.app.KeyguardManager.KeyguardLock;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;

import com.live.activity.LiveAlarmActivity;

public class LiveReceiver extends BroadcastReceiver {

	@SuppressWarnings("static-access")
	@Override
	public void onReceive(Context context, Intent intent) {

		// 点亮屏幕
		PowerManager pm = (PowerManager) context.getSystemService(context.POWER_SERVICE);
		WakeLock mWakelock = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.SCREEN_DIM_WAKE_LOCK,
				"SimpleTimer");
		mWakelock.acquire();

		// 自动解锁
		KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(context.KEYGUARD_SERVICE);
		KeyguardLock keyguardLock = keyguardManager.newKeyguardLock("");
		keyguardLock.disableKeyguard();

		// 弹出提醒对话框
		intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		intent.setClass(context, LiveAlarmActivity.class);
		context.startActivity(intent);
	}
}
